/**
 * @(#)BaseSupportAction.java
 * Copyright (C) 2003-2010 iocn.org All rights reserved
 */
package org.iocn.core.web.struts2;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;


/**
 * Struts2 Action基类.
 * 
 * @author <b>Oxidy</b>, Copyright &#169; 2010
 * @version 0.1,2010-6-7
 */
public class BaseSupportAction extends ActionSupport {

    private static final long serialVersionUID = 3686939512371956636L;
    /**
     * 取得HttpSession的简化函数
     */
    public static HttpSession getSession() {
        return ServletActionContext.getRequest().getSession();
    }
    /**
     * 取得HttpSession的简化函数
     */
    public static HttpSession getSession(boolean isNew) {
        return ServletActionContext.getRequest().getSession(isNew);
    }
    /**
     * 取得HttpSession中Attribute的简化函数
     */
    public static Object getSessionAttribute(String name) {
        HttpSession session = getSession(false);
        return (session != null ? session.getAttribute(name) : null);
    }
    /**
     * 取得HttpRequest的简化函数
     */
    public static HttpServletRequest getRequest() {
        return ServletActionContext.getRequest();
    }
    /**
     * 取得HttpRequest中Parameter的简化方法
     */
    public static String getParameter(String name) {
        return getRequest().getParameter(name);
    }
    /**
     * 取得HttpResponse的简化函数
     */
    public static HttpServletResponse getResponse() {
        return ServletActionContext.getResponse();
    }
}
